<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript"
	src="${ctx}/resources/js/datatable-query.js"></script>
<div class="row-fluid">
	<div class="span12">
		<div class="box gradient">
			<div class="title">
				<h4>
					<span>Facility</span> <span class="box-form right">
					<!-- 
					 <a
						href="${ctx}/admin/micasa-resident/create/" class="btn btn-mini">Create</a>
						 -->
					</span>
				</h4>
				<a href="#" class="minimize">Minimize</a>
			</div>
			<div class="content clearfix scrollable">
				<table class="ajaxTable display table table-bordered">
					<thead>
						<tr>
						<th><a id="select_all"><span
							class="icomoon-icon-checkmark-2"></span></a></th>
							<th>Name</th>
							<th>Code</th>
							<th>Description</th>
							<th>Facility Type</th>
							<th>Auto Confirm</th>
 						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
</div>


<script type="text/javascript">

var render = false;
var oTime = "";
var oTable;
$(document).ready(function () {


	
	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs": [
		  { 'bSortable': false, 'aTargets': [0] }
		], 
		"sAjaxSource": '${ctx}/admin/facility/',
		"fnInitComplete": function (oSettings, json) { }
	});
	var name = $("<input>").attr({
		type: "text",
		field: "name",
		op: "cn",
		placeholder: "name",
		class: "filterdata"
	});
	johnny.initTableQuery(name);
 
	var auto = {
			id : 'auto',
			text  : 'Auto Confirm',
			domain : "Facility",
			operation : "Auto ",
			url : "${ctx}/admin/facility/auto/"
	};
	johnny.tableBtn(auto);
	
	
	var manual = {
			id : 'manual',
			text  : 'Manually Confirm',
			domain : "Facility",
			operation : "Manual",
			url : "${ctx}/admin/facility/manual/"
	};
	johnny.tableBtn(manual);
	
	
});
function updateGrid() {
	window.clearTimeout(oTime);
	oTime = setTimeout(function () { oTable.fnDraw(); }, 500);
}

var columnHeader = ['','name','code', 'description', 'facilityType','autoConfirm '];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
		subArray.push(value);
  		subArray.push(json.result[i].name);
		subArray.push(json.result[i].code); 
		subArray.push(json.result[i].description);
		subArray.push(json.result[i].facilityType);
 		subArray.push((json.result[i].autoConfirm)? "Auto":"Manual");
 		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}


function actionHtml(id) {
return	johnny.getEditHtml("${ctx}/admin/micasa-resident/"+id+"/edit/");
}
</script>
 
<body>